#include <bits/stdc++.h>
using namespace std;

#define ONLINE_JUDGE

#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
	{                                         \
		cerr << "\033[32;1m" << #x << " -> "; \
		err(x);                               \
	}
void err()
{
	cerr << "\033[39;0m" << endl;
}
template <typename T, typename... A>
void err(T a, A... x)
{
	cerr << a << ' ';
	err(x...);
}
#else
#define dbg(...)
#endif

typedef long long LL;

const int N = 1e5 + 50, M = 2, K = 30;

struct bfsNode
{
	int path;
	int nodeId;
	bfsNode(int path = 0, int nodeId = 0) : path(path), nodeId(nodeId) {}
};

namespace trie
{

struct node
{
	int a, nxt[M];
};

struct Trie
{
	node dat[N * K + 100];
	int root;
	int dcnt;
	int newNode()
	{
		dat[dcnt].a = 0;
		memset(dat[dcnt].nxt, -1, sizeof(dat[dcnt].nxt));
		return dcnt++;
	}

	void init()
	{
		dcnt = 0;
		root = newNode();
	}

	void insert(int x)
	{
		static int s[31];
		int len = 0;
		while (x)
		{
			s[len++] = x % M;
			x /= M;
		}
		for (; len < K;)
			s[len++] = 0;
		reverse(s, s + len);
		assert(len == K);
		int now = root;
		for (int i = 0; i < len; ++i)
		{
			++dat[now].a;
			if (dat[now].nxt[s[i]] == -1)
				dat[now].nxt[s[i]] = newNode();
			if (i == len - 1)
				dbg("insert", now);
			now = dat[now].nxt[s[i]];
		}
		++dat[now].a;
	}
};
} // namespace trie

trie::Trie tr;

int sonId(const trie::node &t)
{
	int res = 0;
	if (~t.nxt[0])
		res += 2;
	if (~t.nxt[1])
		res += 1;
	// dbg(res);
	return res;
}

int main(int argc, char const *argv[])
{
	tr.init();

	int n;
	static int a[N];
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
		tr.insert(a[i]);
	}

	for (int i=0; i<tr.dcnt; ++i)
		dbg(i, tr.dat[i].a, tr.dat[i].nxt[0], tr.dat[i].nxt[1]);
	// return 0;
	static bfsNode q[N * 10];
	int st = 0, ed = 0;

	q[ed++] = bfsNode(0, tr.root);

	int ans = 0;

	for (int _ = 0; _ < K; ++_)
	{
		dbg(_);
		int cnt[4] = {0, 0, 0, 0};
		for (int i = st; i < ed; ++i)
		{
			cnt[sonId(tr.dat[q[i].nodeId])]++;
		}
		int olded = ed;
		assert(cnt[0] == 0);
		dbg(cnt[0], cnt[1], cnt[2], cnt[3]);
		if (cnt[1] + cnt[2])
		{
			for (int i = st; i < olded; ++i)
			{
				trie::node &curNode = tr.dat[q[i].nodeId];
				int curId = sonId(tr.dat[q[i].nodeId]);

				if (curId == 2)
				{
					dbg("curId=2", q[i].path, q[i].nodeId);
					q[ed++] = bfsNode(q[i].path << 1, curNode.nxt[0]);
				}
				else if (curId == 1)
				{
					dbg("curId=1", q[i].path, q[i].nodeId);
					q[ed++] = bfsNode(q[i].path << 1 | 1, curNode.nxt[1]);
				}
			}
			ans <<= 1;
		}
		else
		{
			for (int i = st; i < olded; ++i)
			{
				trie::node &curNode = tr.dat[q[i].nodeId];
				q[ed++] = bfsNode(q[i].path << 1, curNode.nxt[0]);
				q[ed++] = bfsNode(q[i].path << 1 | 1, curNode.nxt[1]);
			}
			ans = ans << 1 | 1;
		}
		st = olded;
	}
	printf("%d\n", ans);
	// dbg(ans, st, ed);
	// for (int i = st; i < ed; ++i)
	// 	dbg(i, q[i].path, q[i].nodeId);
	// printf("%d\n", q[st].path);
	return 0;
}